<script setup lang="ts">
import type { generate } from '@vue/compiler-core';
import { ref } from 'vue';
import {useMetadataStore} from '@/store/MetadataStore'
import {chainSendAndRequest} from '@/utils/SocketDUtil.js'
const metadataStore = useMetadataStore()
const templateRootPath = ref('')
const destPath = ref('')

const generate = (type)=>{
  let {packagePath,selectedMDlist} = metadataStore
  let MDlist = selectedMDlist()
  let url = ''
  switch(type){
    case 'template': url = '/templateResult/templateByBeetl';break;
    case 'excle':url = '/templateResult/metadata2Excel';break;
  }
  chainSendAndRequest(url,{
    destPath:destPath.value,
    templateRootPath:templateRootPath.value,
    metadatas:MDlist
  }).then((resp)=>{
    console.log('resp',resp)
  })
}

const selectDir = (value,ev)=>{
  const handle = window.showSaveFilePicker(opts);
  console.log(handle)
}
</script>

<template>
  <div class="border">
    <a-space direction="vertical" :style="{ width: '100%'}">
      <a-tag color="red">
        <template #icon>
          <icon-eye />
        </template>
        注意：目录需要以目录分隔符结尾 -win: \  -linux: /
      </a-tag>
      
      <a-input v-model="templateRootPath" placeholder="模版根目录" allow-clear >
        </a-input>

      <a-input v-model="destPath" placeholder="输出目录" allow-clear />
      <a-row>
        <a-col :span="12">
          <a-button type="primary" long @click="generate('template')" >模版生成</a-button>
        </a-col>
        <a-col :span="12">
          <a-button type="primary" status="success" long @click="generate('excle')" >EXCLE生成</a-button>
        </a-col>
      </a-row>
    </a-space>
  </div>

</template>

<style scoped>
.border{
  border: solid 1px white;
  padding-top: 20px;
}
</style>